/**
* 虚函数
*/

#include <iostream>
#include <tuple>

class Base {
public:
    virtual void demo1() {
        std::cout << "Base::demo1" << std::endl;
    }

    virtual void demo2();

    // 基类希望派生类直接继承而不改变的函数
    void demo3() {
        std::cout << "Base::demo3" << std::endl;
    }
};


class Derived : public Base {
public:
    void demo1() {
        std::cout << "Derived::demo1" << std::endl;
    }

    void demo2() {
        std::cout << "Derived::demo2" << std::endl;
    }

    void demo3() {
        std::cout << "Derived::demo3" << std::endl;
    }
};

class Derived1 : public Derived {
public:
    void demo1() {
        std::cout << "Derived1::demo1" << std::endl;
    }

    void demo3() {
        std::cout << "Derived1::demo3" << std::endl;
    }
};


void demo(Base &b) {
    b.demo1();
    b.demo2();
    b.demo3();
}

void demo1(Derived &d) {
    d.demo1();
}

int main() {
    Derived d;
    demo(d);

    std::cout << "===\n";

    Derived1 d1;
    demo(d1);

    std::cout << "===\n";
    demo1(d1);

    return 0;
}